<template>
  <el-dialog :title="title" :visible.sync="dialogFormVisible" width="682px" @close="close" append-to-body>
    <el-table v-loading="listLoading" ref="listTable" stripe :data="list"
                  :element-loading-text="elementLoadingText" border
                   height="calc(100vh - 520px)">
                  <template slot="empty">
                    <el-empty :image-size="200"></el-empty>
                  </template>                 

                  <el-table-column show-overflow-tooltip prop="user_name" label="操作账号" align="center"
                    ></el-table-column>
                  <el-table-column show-overflow-tooltip prop="operate_time" label="操作时间" align="center"></el-table-column>
                  <el-table-column show-overflow-tooltip prop="content" label="操作内容" align="center" ></el-table-column>
<!--                  <el-table-column show-overflow-tooltip label="督察结果" align="center" width="160">                   -->
<!--                  </el-table-column>                 -->
                </el-table>
                <el-pagination background :current-page="queryForm.pageNo" :page-size="queryForm.pageSize"
                  :layout="layout" :total="total" @size-change="handleSizeChange"
                  @current-change="handleCurrentChange2"></el-pagination>
    <div slot="footer" class="dialog-footer" style="text-align:center;">
     
      <el-button @click="close">关 闭</el-button>

    </div>
  </el-dialog>
</template>

<script>
import { getOneLog } from '@/api/warningOrder'
export default {
  name: 'dcRizhi',
  data() {
    return {
      queryForm: {
        pageNo: 1,
        pageSize: 10,
        id: '',
      },
      list: null,
      listLoading: true,
      layout: 'total, sizes, prev, pager, next, jumper',
      total: 0,
      selectRows: '',
      elementLoadingText: '正在加载...',
      title: '',
      dialogFormVisible: false,      
    }
  },
  created() {

  },
  methods: {
    showDia(row) {
      if (!row) {
        this.title = '添加'
      } else {
        this.title = '日志'
        this.queryForm.id = row.id
        this.fetchData()
      }
      this.dialogFormVisible = true
    },    
    close() {     
      this.dialogFormVisible = false
    }, 
    handleSizeChange(val) {
      this.queryForm.pageSize = val
      this.fetchData()
    },
    handleCurrentChange2(val) {
      this.queryForm.pageNo = val
      this.fetchData()
    },
    async fetchData() {
      this.listLoading = true
      const { data, totalCount } = await getOneLog(this.queryForm)
      console.log(data)
      this.list = data.list
      this.total = data.total
      setTimeout(() => {
        this.listLoading = false
      }, 300)
    },   
  },
}
</script>
